// 封装一个接口的回调函数，
(function (w) {
    const NewsUrl = 'http://127.0.0.1:8080/api/v1'
    const bigNews = {
        user_login: NewsUrl + '/admin/user/login',// 用户登陆
        user_info: NewsUrl + '/admin/user/info', // 获取用户信息
        user_detail: NewsUrl + '/admin/user/detail',//用户详情
        user_edit: NewsUrl + '/admin/user/edit',//用户编辑
        category_list: NewsUrl + '/admin/category/list',//文章类别查询 ,文章列表
        category_add: NewsUrl + '/admin/category/add',//文章类别新增
        category_search: NewsUrl + '/admin/category/search',//文章类别搜索
        category_edit: NewsUrl + '/admin/category/edit',//文章类别编辑
        category_delete: NewsUrl + '/admin/category/delete',//文章类别删除
        article_query: NewsUrl + '/admin/article/query',//文章搜索
        article_publish: NewsUrl + '/admin/article/publish',//文章发布
        article_search: NewsUrl + '/admin/article/search',//文章信息查询
        article_edit: NewsUrl + '/admin/article/edit',//文章编辑
        article_delete: NewsUrl + '/admin/article/delete',//文章删除
        comment_search: NewsUrl + '/admin/comment/search',//文章评论列表
        comment_pass: NewsUrl + '/admin/comment/pass',//文章评论通过
        comment_reject: NewsUrl + '/admin/comment/reject',//文章评论不通过
        comment_delete: NewsUrl + '/admin/comment/delete',//文章评论删除
        data_info: NewsUrl + '/admin/data/info',//获取统计数据
        data_article: NewsUrl + '/admin/data/article',//日新增文章数量统计
        data_category: NewsUrl + "/admin/data/category",  //各类型文章数量统计
        data_visit: NewsUrl + '/admin/data/visit',  //日文章访问量
        // get_comment: NewsUrl + '/index/get_comment',//文章评论列表
    }
    w.bigNews = bigNews
})(window)
// 把之前放在jquery后面的代码调回来，不要修改源代码
$.ajaxSetup({
    beforeSend(xhr) {
        // 这里是全局的, 即使是登录的请求也会进来这个逻辑
        // 需要先判断, 如果已经登录 有 token 才带上
        if (localStorage.getItem('bignews_token')) {
            xhr.setRequestHeader('Authorization', localStorage.getItem('bignews_token'))
        }
    },
    error(xhr, status, error) {
        if (error == "Forbidden") {
            alert('请先登录')
            location = './login.html'
        }
    }
})